import React from 'react';
import {BrowserRouter,Route,Routes,Navigate} from "react-router-dom"
import router from "./router"
const Index = () => {
    const mapRouter=(route)=>{
        return route.map((v,i)=>{
            return v.path?
            <Route path={v.path} key={i} element={v.element}>
                {
                    v.children&&mapRouter(v.children)
                }
            </Route>
            :<Route key={i} path={v.from} element={<Navigate to={v.to}  />}></Route>
        })
    }
    return (
        <BrowserRouter>
            <Routes>
            {
                mapRouter(router)
            }
            </Routes>
        </BrowserRouter>
    );
}

export default Index;
